<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
  <script src="../../vue.js"></script>
  <style>
    .active {
      font-size: 50px;
      color: greenyellow;
    }
  </style>
</head>
<body>
  <div id="root">
    <my-header 
      v-bind="obj"
      :user-name="userName"
      :password="password"
      :phone="phone"
    ></my-header>
    <my-header abc="aaabbbcc" class="active"></my-header>
  </div>
  <script>
    Vue.config.productionTip = false

    const MyHeader = {
      inheritAttrs: false,
      // props: [
      //   'title', 
      //   'msg1', 
      //   'msg2', 
      //   'userName'
      // ],
      props: {
        title: {
          type: String
        },
        userName: {
          type: String
        },
        msg2: {
          type: Object
        },
        password: {
          type: [String, Boolean, Number],
          // required: true,
          default() {
            // 10000行代码
            return 'abc' + 123
          }
        },
        phone: {
          type: String,
          validator(value) {
            return value.length === 11
          }
        },
        // abc: {
        //   type: String
        // }
      },

      template: `
        <h1>{{title}} {{msg2}} {{password}}</h1>
      `,
      mounted() {
      },
    }

    var vm = new Vue({
      el: '#root',
      data: {
        obj: {
          title: 'true',
          msg1: 2,
          msg2: {x: ['a', 'b']}
        },
        userName: 'admin',
        password: 123,
        phone: '13456789011'
      },
      components: {
        MyHeader
      }
    })
  </script>
</body>
</html>